<?php

/**
 * Libraries_Reporter File
 * 
 * Short file description
 *
 * PHP Version: 5.3.26
 * 
 * @category Libraries_Reporter
 * @package  Libraries_Reporter_Package
 * @author   
 * @license  
 * @link     
 */

// put your namespace and use here

/**
 * Libraries_Reporter class
 * 
 * Class description
 *
 * @category Libraries_Reporter_Controller
 * @package  Libraries_Reporter_Package
 * @author   
 * @license  
 * @link     
 */

class Reporter extends Jasper\Jasper
{

	protected $host = '192.168.1.251:8080';
	protected $user = 'joeuser';
	protected $pass = 'joeuser';

	public $folder = '/ITBM_iWAS_Reports/';
	public $rootFolder = '/reports';

	public function __construct()
	{

		return parent::__construct($this->host,  $this->user , $this->pass);

	}

	/**
	  * viewFolder Method
	  *
	  * @param string 
	  * @param int    
	  *
	  * @return void
	  */
	public static function viewFolder()
	{
		$client = new Reporter;
		$reports = $client->getFolder($client->rootFolder.$client->folder);

		foreach($reports as $report){

			$stringName = str_replace($client->rootFolder.$client->folder, '', $report->getUriString());

			if((Auth::user()->sur_id == 2 ||  Auth::user()->sur_id == 4 ) && $stringName == 'Laporan___Senarai_Kehadiran'):

				$reportList[$stringName] = $report->getLabel();

			elseif((Auth::user()->sur_id == 1 ||  Auth::user()->sur_id == 3 )):

				$reportList[$stringName] = $report->getLabel();

			endif;

			// $reportList[$stringName] = $report->getLabel();//str_replace('_',' ',$stringName);
		}

		asort($reportList);

		$data = array('Sila Pilih');

		foreach ($reportList as $key => $val) {
		    $data[$key] = $val;
		}

		return $data;
	}


}
